﻿using AbpPcClient.WpfClient.Common;
using AbpPcClient.WpfClient.Service.Login;
using AbpPcClient.WpfClient.ViewModels;
using AbpPcClient.WpfClient.Views;
using Prism.DryIoc;
using Prism.Ioc;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace AbpPcClient.WpfClient
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : PrismApplication
    {

        protected override Window CreateShell()
        {
            //启动页面
              return Container.Resolve<MainView>();
            // return Container.Resolve<IndexView>();
          
            


        }
        /// <summary>
        /// 初始化方法
        /// </summary>
        protected override void OnInitialized()
        {
            var dialog = Container.Resolve<IDialogService>();
            dialog.ShowDialog("LoginView", callback =>
            {
                if (callback.Result != ButtonResult.OK)
                {
                    Environment.Exit(0);
                    return;
                }
                var service = App.Current.MainWindow.DataContext as IConfigureService;
                if (service != null)
                    service.Configure();
                base.OnInitialized();
            });

        }

        /// <summary>
        /// prism的视图和model的映射
        /// </summary>
        /// <param name="containerRegistry"></param>
        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            containerRegistry.Register<LoginService>();
            containerRegistry.RegisterForNavigation<WuZiCaiGou, WuZiViewModel>();
            containerRegistry.RegisterForNavigation<WuZiLingY, WuZiLingYViewModel>();
            containerRegistry.RegisterForNavigation<WuZiList, WuZiListViewModel>();

            containerRegistry.RegisterForNavigation<TestView, TestViewModel>();
            containerRegistry.RegisterForNavigation<LoginView, LoginViewModel>();
            containerRegistry.RegisterForNavigation<IndexView, IndexViewModel>();
            containerRegistry.RegisterForNavigation<MainView, MainViewModel>();
            containerRegistry.RegisterForNavigation<TenantManagerView, TenantManagerViewModel> ();
        }
    }
}
